<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .yanse {
      background-color: lightcoral;
    }
  </style>
  <script src="./scripts/vue.js"></script>
</head>

<body>
  <div id="app">
    <input class="yanse" type="text" v-color="bgc">
  </div>

  <script>
    
    // 全局指令
    Vue.directive('color', {
      bind: function (el, binding) {
        console.log(binding)
        el.style.backgroundColor = binding.value
      }
    })
  
    var vm = new Vue({
      el: '#app',
      data: {
        bgc: 'lightgreen'
      }
    })
  </script>
</body>

</html>